/**
 * Created by evil on 16-12-21.
 */
$(function ()
{
    $(document.body).pjax('a.pjax', '#container', {timeOut: 10000});

    setting.init();
    setting.setsidebar();
});

var setting = {
    init: function ()
    {
        var url = window.location.pathname.replace("/index/setting/", "");

        if (url == "/index/setting")
            $.get('/setting/key', function (data)
            {
                $('#container').html(data);
            });
        else
        {
            $.get('/setting/' + url, function (data)
            {
                $('#container').html(data);
            });

            var tree = $('.treeview');
            tree.removeClass('active');

            tree.each(function ()
            {
                if (this.innerHTML.indexOf(url) > 0)
                    $(this).addClass('active');
            });
        }
    },
    setsidebar: function ()
    {
        $('.sidebar-menu').height($(document).height() - $('.navbar').height());
        $.sidebarMenu($('.sidebar-menu'));

        $('.treeview').click(function ()
        {
            $('.treeview').removeClass('active');
            $(this).addClass('active');
        });
    }
};